function Foo() {
  let id = 1; // id是所有实例私有的数据，不能被外界直接访问
  this.getId = () => {
    return id;
  };
  this.addId = () => {
    id++;
  }
};

const a = new Foo();
const b = new Foo();

console.log(a.getId()); // 1
console.log(b.getId()); // 1
a.addId();

console.log(a.getId()); // 2
console.log(b.getId()); // 1

console.log('********************************');

// 实例间共享私有数据，正常共享数据是放在原型上，但是原型上是直接可以访问到的
const XX = (function () {
  let id = 1;

  function Inner() {}
  Inner.prototype.getId = () => {
    return id;
  };

  Inner.prototype.setId = (val) => {
    id = val;
  }
  return Inner;
})();

const x1 = new XX();
const x2 = new XX();

console.log(x1.getId()); // 1
console.log(x2.getId()); // 1
x1.setId(2);
console.log(x1.getId());  // 2
console.log(x2.getId());  // 2

console.log('********************************');

// 原型上共享数据实例
const AA = function (){}

AA.prototype.
